Release 10.1A: OpenEdge Data Management:
SQL Reference
PREPARE
Parses and assigns a name to an ad hoc or dynamically generated SQL statement for execution. You use a
PREPAREstatement in a series of steps that allows a program to accept or generate SQL statements at run time.Syntax
statement_nameA name for the dynamically generated statement.
DESCRIBE,EXECUTE, andDECLARECURSORstatements refer to this statement_name. A statement_name must be unique in a program.statement_stringSpecifies the SQL statement to be prepared for dynamic execution. You can use either the name of a C language string variable containing the SQL statement, or you can specify the SQL statement as a quoted literal. If there is an SQL syntax error, the
PREPAREstatement returns an error in theSQLCA.Examples
The first example is a code fragment from the
DynUpdfunction in sample program3DynUpd.pc, which illustrates dynamic processing of anUPDATEstatement:
This example is a code fragment from the
DynSelfunction in sample program4DynSel.pc, which illustrates dynamic processing of aSELECTstatement:
Notes
- A statement string can have one or more references to input variables. These variables represent values supplied at run time to:
- A program supplies an input variable to a
PREPAREstatement either as a substitution name or as a parameter marker:- The
USINGclauses ofEXECUTEandOPENstatements identify host language storage. The values in this storage expand a statement string, replacing a substitution name or a parameter marker. You can design your program to execute the same prepared statement many times in a transaction, supplying different values for input variables for each execution. If youCOMMITorROLLBACKthe transaction, you mustPREPAREthe statement string again.Authorization
Must have DBA privileges or authorization for the SQL statement being used.
Related statements
EXECUTE, OPEN, CLOSE, FETCH
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |